<?php
/**
 * The Header for our DMCI.
 *
 * Displays all of the <head> section and everything up till <div id="header">
 *
 * @package WordPress
 * @subpackage dmcitheme
 
 */
 
//Get Project Categories
$categories = get_project_categories();
//Get Project Locations
$locations = get_project_locations();
					
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <?php language_attributes(); ?> xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' |'; } ?> <?php bloginfo('name'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="robots" content="index,follow" />
<link href='http://fonts.googleapis.com/css?family=Chivo:400,900,400italic|Hammersmith+One' rel='stylesheet' type='text/css'>
<?php wp_head(); ?>
<!--[if IE 7]>
<script type="text/javascript">
$(document).ready(function() {
  $(function() {
       var zIndexNumber = 1000;
       // Put your target element(s) in the selector below!
       $("div").each(function() {
	   		if( $(this).hasClass('ftitle') ) {
				$(this).css('zIndex', 9);
			}
			else if( $(this).hasClass('slider-text') ) {
				$(this).css('zIndex', 1000);
			}
			else {
				$(this).css('zIndex', zIndexNumber);
				zIndexNumber -= 10;
			}
			
			   
			   
       });
	});
});
</script>
<![endif]-->
<script type="text/javascript">
	$(document).ready(function(e) {
       		
		var projectLists = [];
		<?php foreach($categories as $cat ) :?>
			projectLists[<?php echo $cat->term_id?>] =  <?php echo build_menu_array('dmci_projects', 'dmci_project_categories', $cat->slug); ?>
		<?php endforeach; ?>

	
		// Get First Project
		var initial_pointer = $('.category li:first a').attr('rel');
		var initital_total = projectLists[initial_pointer].length;
		
		
		
		$('.category li a').hover(function(e){
			$('.icon.active').removeClass('active');
			$(this).find('.icon').addClass('active').fadeIn();
			var arr_pointer = $(this).attr('rel');
			var total = projectLists[arr_pointer].length;
			var clear = '<div class="clear">&nbsp;</div>';
			var breakpoint = '';
			var col1 = '';
			var col2 = '';
			var ctr = 0;
			
			
			if(total > 10) {
				breakpoint = total/2;
				$('#plistwrap').css('width', '650px');
			}
			else{
				$('#plistwrap').css('width', '450px');
			}
			

			$.each(projectLists[arr_pointer], function(index, object){
				if(breakpoint){
					if(ctr < breakpoint)
						col1 += '<a href="'+object[1]+'">'+object[0]+'</a>';	
					else
						col2 += '<a href="'+object[1]+'">'+object[0]+'</a>';
				}
				else 
					col1 += '<a href="'+object[1]+'">'+object[0]+'</a>';
				ctr++;
			});
			
			
			
			if(breakpoint){
				$('#projects_subcategory .col1').show().html('').append(col1);
				$('#projects_subcategory .col2').show().html('').append(col2);
			}
			else {
				$('#projects_subcategory .col1').show().html('').append(col1);
				$('#projects_subcategory .col2').hide();
			}
			
			
		});
		
		var count = 3;
		$('#loadMore').click( function(e) {
			loadArticle(count);  
			count+=count;
			e.preventDefault();
		});
	})
	<?php if( is_front_page() ) : ?>
	
	function loadArticle(pageNumber) {  
    $.ajax({  
        url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",  
        type:'POST',  
        data: "action=infinite_scroll&page_no="+ pageNumber,
        success: function(html){  
			$("#content").append(html);    // This will be the div where our content will be loaded  
        }  
    });  
    return false;  
	}
	<?php endif; ?>
</script>
</head>

<body>
<div class="main-wrapper">
<div id="header">
    <div class="container">
        <div id="logo">
			<h1>
				<a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a>
			</h1>
	   </div>
	   
	   <form id="proj_search" method="get" action="/project-search/">

	   		<div class="title">What are you looking for?</div>
		   <div class="sel-container">
				<select name="project_type" tabindex="1" class="pretty dk">
                	<option value="">Project Type</option>
                <?php foreach( $categories as $cat ): ?>
                	<option value="<?php echo $cat->slug; ?>"><?php echo $cat->name; ?></option>
                <?php endforeach;?>				  
				</select>
			</div>
			
			<div class="sel-container">
				<select name="project_location" tabindex="1" class="pretty dk">
				  <option value="">Project Location</option>
                  <?php foreach ($locations as $loc ) : ?>
                  		<option value="<?php echo $loc->slug; ?>"><?php echo $loc->name; ?></option>
                  <?php endforeach; ?>
                  </select>
			</div>
			
			<input type="submit" value="Submit"	 name="submit"  />
	   </form>
	
		<form id="site_search" method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>" role="search">
			<div class="title">Search Site</div>
			<input type="text" class="site-search-input" name="s" id="s" value="Enter Keywords" />
			<input type="submit" name="submit" value="Search" />
		</form>
        <div class="clear">&nbsp;</div>
    </div>
</div>

<div id="menu_holder">
	<ul class="container" id="nav">
    	<li>
        	<a href="<?php echo home_url() ; ?>" <?php if( is_front_page() ) :?> class="selected" <?php endif;?>><div class="nav-brdr-top">&nbsp;</div><span>HOME</span></a>
        </li>
        <li>
        	<a href="/about-us/" <?php if( is_page('about-us') ): ?> class="selected" <?php endif;?> ><div class="nav-brdr-top">&nbsp;</div><span>ABOUT US</span></a>
        </li>
        <li>
        	<a href="/project-categories/" <?php if( is_single() == 'dmci_projects' || is_post_type_archive( 'dmci_projects') || is_page('projects') ): ?> class="selected" <?php endif;?>><div class="nav-brdr-top">&nbsp;</div><span>PROJECTS</span></a>
            
            <div class="project-lists" id="plistwrap">
            	<div class="content">
            	<ul class="category">
                	                 
                    <?php foreach($categories as $cat) :?>
                    	<li>
                        	<a href="<?php echo get_term_link( $cat ) ?>" rel="<?php echo $cat->term_id; ?>">
                        	<div class="icon">&nbsp;</div><span><?php echo $cat->name; ?></span>
                           	</a>
                        </li>
					<?php endforeach;?>
					
                </ul>
				<div class="sub-category" id="projects_subcategory">
					<div class="col1">&nbsp;</div>
					<div class="col2">&nbsp;</div>
					<div class="clear">&nbsp;</div>
				</div>
                 <div class="clear">&nbsp;</div>
                </div>
               
            </div>
            
        </li>
        <li>
        	<a href="/contact-us/"  <?php if( is_page('contact-us') ): ?> class="selected" <?php endif;?> ><div class="nav-brdr-top">&nbsp;</div><span>CONTACT US</span></a>
        </li>
    </ul>
	<div class="clear">&nbsp;</div>
</div>
